package com.atguigui.leetcode;

import java.util.Arrays;

/**
 * 940.不同的子序列 II
 * Project: leetcode
 * Package: com.atguigui.leetcode
 * Version: 1.0
 * <p>
 * Created by WJX on 2022/10/14 11:29
 */
public class P940DistinctSubsequencesIi {
    public static void main(String[] args) {
        Solution solution = new P940DistinctSubsequencesIi().new Solution();
        // TO TEST
    }


    class Solution {
        private final long MOD = (long) 1e9 + 7;

        public int distinctSubseqII(String s) {
            long[] f = new long[26];
            int n = s.length();
            for (int i = 0; i < n; i++)
                f[s.charAt(i) - 'a'] = (1 + Arrays.stream(f).sum()) % MOD;
            return (int) (Arrays.stream(f).sum() % MOD);
        }
    }
}
